package com.weirong.smartvault.backservice.entity_model;

import com.weirong.smartvault.common.tools.spring.context.SpringContextUtil;
import com.weirong.smartvault.dao.CashboxUnitRepository;
import com.weirong.smartvault.dao.ForeignCurrencyTypeRepository;
import com.weirong.smartvault.entity.CashboxConf;
import com.weirong.smartvault.entity.CashboxUnit;
import com.weirong.smartvault.entity.ForeignCurrencyType;

/**
 * 于2017/12/7由 KFEB4 创建 .
 */
public class CashboxConfModel {
    CashboxConf cashboxConf;
    ForeignCurrencyTypeRepository foreignCurrencyTypeRepository;
    CashboxUnitRepository cashboxUnitRepository;

    public CashboxConfModel(CashboxConf cashboxConf) {
        this.cashboxConf = cashboxConf;
        foreignCurrencyTypeRepository = SpringContextUtil.getBean(ForeignCurrencyTypeRepository.class);
        cashboxUnitRepository = SpringContextUtil.getBean(CashboxUnitRepository.class);
    }

    public Integer getSlotNo() {
        return this.cashboxConf.getSlotNo();
    }

    public String getCode() {
        return cashboxConf.getCode();

    }

    public Integer getDenominationValue() {
        return cashboxConf.getDenominationValue();
    }

    public String getCashName() {
        String code = cashboxConf.getTypeCode();
        ForeignCurrencyType foreignCurrencyType = foreignCurrencyTypeRepository.getByCode(code);
        return foreignCurrencyType.getName();
    }

    public String getUnitName() {
        Integer no = cashboxConf.getUnitNo();
        CashboxUnit cashboxUnit = cashboxUnitRepository.findCashboxUnitByNo(no);
        return cashboxUnit.getName();
    }

    public String getDescription() {
        return cashboxConf.getDescription();
    }
}
